home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / spitfire / bftimepc.zip / BFTIME.PAS < prev    next >
Pascal/Delphi Source File  |  1995-03-11  |  5KB  |  146 lines

  1. Program BFTIME; {(C) 1995 - Brian Leiter - 03/11/1995}
  2.  
  3. Uses DOS,CRT;
  4.  
  5. Var H,M,S,Hund         : Word;       { For GetTime         }
  6.     FTime              : Longint;    { For Get/SetFTime    }
  7.     DT                 : DateTime;   { For Pack/UnpackTime }
  8.     Year,Month,Day,Dow : Word;       { For Date            }
  9.     F,F1               : Text;       { For File Name       }
  10.     Log                : Boolean;    { For Log File        }
  11.     Count              : Integer;    { For File Count      }
  12.     DirInfo            : SearchRec;  { For Search Info     }
  13.  
  14. Const Days : Array [0..6] of String[9] =
  15.       ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  16.       CDrive: Byte = 0;
  17.  
  18. Procedure Help;
  19. Begin
  20.   ClrScr;
  21.   Textcolor(9);Writeln('■ BFTIME v1.0 - A File Date/Timestamp Updater Program ■');
  22.   Textcolor(15);Writeln('───────────────────────────────────────────────────────');
  23.   Writeln('');Textcolor(14);
  24.   Writeln('Command Line Usage:  BFTIME [FILE MASK] (Log File)');
  25.   Writeln('');Textcolor(11);
  26.   Writeln('Ex 1: BFTIME *.ZIP                    <───< No Log File');
  27.   Writeln('Ex 2: BFTIME *.ZIP C:\LOG\BFTIME.LOG  <───< Log File Used');
  28.   Textcolor(7);
  29.   Writeln('                 ');
  30.   Writeln('      │      │     └──────────────────< Path & Name Of Log File');
  31.   Writeln('      │      │');
  32.   Writeln('      │      └────────────────────────< Mask For Files To Be Updated');
  33.   Writeln('      │');
  34.   Writeln('      └───────────────────────────────< Executionable Program File');
  35.   Writeln('');Sound(850);Delay(350);NoSound;Sound(650);Delay(350);NoSound;Sound(850);Delay(350);NoSound;
  36.   Halt;
  37. End;
  38.  
  39. Procedure CheckParams;
  40. Begin
  41.   Log:=False;
  42.   If (ParamCount=0) or (ParamCount>2) Then Help;
  43.   If ParamCount=2 Then Log:=True;
  44. End;
  45.  
  46. Procedure DateNow;
  47. Begin
  48.   GetDate(Year,Month,Day,Dow);
  49.   If Log=True Then
  50.   Begin
  51.     Assign(F1,ParamStr(2));
  52.     {$I-}Reset(F1);{$I+}
  53.     IF IOResult<> 0 Then Rewrite(F1);
  54.     Append(F1);
  55.     Writeln(F1,'START  LOG: ',Days[Dow],', ',Month:0, '-', Day:0, '-', Year:0,' ■ BFTIME v1.0');
  56.   End;
  57. End;
  58.  
  59. Function LeadingZero(W : Word) : String;
  60. Var S : String;     { For File Name       }
  61.  
  62. Begin
  63.   Str(W:0,S);
  64.   If Length(S) = 1 Then S := '0' + S;
  65.   LeadingZero := S;
  66. End;
  67.  
  68. Procedure Importit;
  69. Begin
  70.   FindFirst(ParamStr(1), Archive, DirInfo);
  71.   While DosError = 0 Do
  72.   Begin
  73.     Count:=Count+1;
  74.     Assign(F,DirInfo.Name);
  75.     Reset(F);
  76.     GetTime(H,M,S,Hund);
  77.     GetDate(Year,Month,Day,Dow);
  78.     GetFTime(F,FTime);
  79.     Gotoxy(1,9);
  80.     Textcolor(14);
  81.     Writeln('■ ',DirInfo.Name,' Was Re-Dated And Re-Timestamped At '
  82.     ,LeadingZero(h),':',LeadingZero(m),':',LeadingZero(s));
  83.     If Log=True Then
  84.     Begin
  85.       Append(F1);
  86.       Writeln(F1,'    ■ ',DirInfo.Name,' Was Re-Dated And Re-Timestamped At '
  87.       ,LeadingZero(h),':',LeadingZero(m),':',LeadingZero(s));
  88.     End;
  89.     UnpackTime(FTime,DT);
  90.     With DT Do
  91.     Begin
  92.       GetDate(Year,Month,Day,Dow);
  93.       Day:=Day;
  94.       Month:=Month;
  95.       Year:=Year;
  96.       Hour := H;
  97.       Min := M;
  98.       Sec := S;
  99.       PackTime(DT,FTime);
  100.       Reset(F);
  101.       SetFTime(F,FTime);
  102.     End;
  103.     Close(F);
  104.     FindNext(DirInfo);
  105.   End;
  106.   Gotoxy(1,10);
  107.   Textcolor(11);
  108.   If Count>=1 Then Writeln('■ Operation Successfull - There Were ',Count,' Files Updated!');
  109.   If Count<=0 Then
  110.   Begin
  111.     Writeln('■ Operation Failed - There Were No Files Matches Found!');
  112.     Sound(350);Delay(350);NoSound; Sound(150);Delay(350);NoSound;
  113.   End;
  114.   If Log=True Then
  115.   Begin
  116.     Append(F1);
  117.     If Count<=0 Then Writeln(F1,'    ■ Operation Failed - No File Match Found ■');
  118.     Writeln(F1,'END OF LOG: BFTIME (C) 1995 Brian Leiter, All Rights Reserved');
  119.     Writeln(F1,'════════════════════════════════════════════════════════════════════════════════');
  120.     Close(F1);
  121.   End;
  122. End;
  123.  
  124. Procedure Logo;
  125. Begin
  126.   Clrscr;
  127.   Textcolor(15);Textbackground(4);
  128.   Writeln('╔════════════════════════════════════════════╗');
  129.   Writeln('║ -=■ BFTIME v1.0 ■=-               03/11/95 ║');
  130.   Writeln('║                                            ║');
  131.   Writeln('║      File Date And Timestamp Updater       ║');
  132.   Writeln('║                                            ║');
  133.   Writeln('║ (C) 1995 Brian Leiter, All Rights Reserved ║');
  134.   Writeln('╚════════════════════════════════════════════╝');
  135.   Textbackground(0);
  136. End;
  137.  
  138. Begin;
  139. CheckParams;
  140. Logo;
  141. DateNow;
  142. Importit;
  143. Textcolor(7);
  144. ;
  145. End.
  146.